<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{$basic.title}</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
	<link href="__LAYUI__/css/layui.css" rel="stylesheet">
    <link href="__LAYUI__/css/ah.css" rel="stylesheet">
</head>
<body>
<div class="wrapper-content">
<div class="ibox">
	<div class="ibox-title"><h3>增加图片</h3>
	</div>
	<div class="ibox-content">
		<form class="layui-form" enctype="multipart/form-data" id="amData" action="{:url('bar/add')}">
				  <div class="layui-form-item">
					<label class="layui-form-label">标题</label>
					<div class="layui-input-block">
					  <input type="text" name="title" lay-verify="required"  placeholder="请输入标题" class="layui-input">
					</div>
				  </div>
				  <div class="layui-form-item">
					<div class="layui-inline">
					  <label class="layui-form-label">位置</label>
					  <div class="layui-input-inline">
						<select name="site">
							{volist name="Think.config.bar_site" id="vo"}
								<option value="{$key}">{$vo}</option>
							{/volist}
						</select>
					  </div>
					</div>
				  </div>
				  <div class="layui-form-item">
					<label class="layui-form-label">URL</label>
					<div class="layui-input-block">
					  <input type="text" name="URL"  placeholder="请输入URL" class="layui-input">
					</div>
				  </div>
				  <div class="layui-form-item">
					<label class="layui-form-label">状态</label>
					<div class="layui-input-inline">
					  <input type="checkbox" name="status"  lay-skin="switch" lay-text="ON|OFF">
					</div>
				  </div>
					<button type="button" class="layui-btn" lay-submit lay-filter="saveData">保存提交</button>
		</form>
	</div>
</div>
</div>
</body>
<script src="__LAYUI__/layui.js"></script>
<script>
  layui.use(['layer','jquery','form'],function(){
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
	var xaoam ={
		  close:function(msg){
			  layer.msg(msg);
			  if(parent.length > 0){
				  let index = parent.layer.getFrameIndex(window.name);
				  parent.layer.close(index);
				  parent.Wxaoam.init();
			  }
			  
		  },
		  tool:function(){
				form.on('submit(saveData)',function(data){
					var action = $(this).parent('form').attr('action');
					var index = parent.layer.getFrameIndex(window.name);
					var Fdata = new FormData(document.getElementById("amData"));
					$.ajax({
						url:action,
						data:Fdata,
						dataType:'json',
						type:'POST',
						contentType: false,
						processData: false,
						success:function(res){
							if(res.code == 200){
								xaoam.close(res.msg);
							}else{
								layer.msg(res.msg);
							}
						}
					})
				  return false; 
				});
		  },
		 init:function(){

	 }
		 
	};

	xaoam.init();
	xaoam.tool();
  });
</script>
</html>
